package main

import (
	"fmt"
	"time"
)

func GetTimeStamp(timeStr string) time.Time {

	timeTemplate1 := "2006-01-02 15:04:05"

	//字符串转时间戳
	stamp, _ := time.ParseInLocation(timeTemplate1, timeStr, time.Local) //使用parseInLocation将字符串格式化返回本地时区时间
	fmt.Println(stamp.Unix())                                            //输出：1546926630
	//时间戳转time.Time
	//fmt.Println(time.Unix(stamp.Unix(), 0))
	//fmt.Println(reflect.TypeOf(time.Unix(stamp.Unix(), 0)))
	return time.Unix(stamp.Unix(), 0)

}
